Dim s As New NotesSession
Dim Subject As String, SendTo As String
Dim Sender As String, SenderN As String
'the address you want the mail to appear to be from
Sender = "FName LName <flname@domain.com>"
SenderN = "FName LName <flname@domain.com@NotesDomain>"
'Alternatively, you could just use:
'Sender = "flname@domain.com"
'SenderN = Sender & "@NotesDomain"
subject = "This is the subject line"
SendTo = "someone@somedomain.com"
Dim DBmbox As New NotesDatabase("servername", "mail.box")
Dim mail As New NotesDocument( DBmbox )
s.ConvertMIME = False ' Do not convert MIME to rich text
Dim body As NotesMIMEEntity
Dim header As NotesMIMEHeader
Dim stream As NotesStream
Dim child As NotesMIMEEntity
Set stream = s.CreateStream
Set body = mail.CreateMIMEEntity
Set header = body.CreateHeader({MIME-Version})
Call header.SetHeaderVal("1.0")
Set header = body.CreateHeader("Content-Type")
Call header.SetHeaderValAndParams({multipart/alternative;boundary="=NextPart_="})
'Add the to field
Set header = body.CreateHeader("To")
Call header.SetHeaderVal(SendTo)
'Add Subject Line
Set header = body.CreateHeader("Subject")
Call header.SetHeaderVal(subject)
'Add the body of the message
Set child = body.CreateChildEntity
Call stream.WriteText("<p>")
Call stream.WriteText("<font face=Verdana color=#0288C1 size=3>")
Call stream.WriteText(|<div class="headerlogo">|)
'If you are referencing any external files, images, javascript, you must use a fully qualified URL/Path
Call stream.WriteText (|<img src="http://yourserver.com/images/somelogo.gif" alt="SomeLogo">|)
Call stream.WriteText(|</div></font>|)
Call stream.WriteText(|...some more HTML |)
Call child.setContentFromText(stream, {text/html;charset="iso-8859-1"}, ENC_NONE)
Call stream.Truncate 'Not sure if I need this
Call stream.Close
Call mail.CloseMIMEEntities(True)
Call mail.replaceItemValue("Form", "Memo")
Call mail.replaceItemValue("Recipients", SendTo)
Call mail.replaceItemValue( "From", SenderN )
Call mail.replaceItemValue( "InetFrom", Sender )
'Since we created the mail in the mail.box, we just need to save it, not send it!
Call mail.Save(True,False)
s.ConvertMIME = True ' Restore conversion